<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <script type="text/javascript" src="__JS__/rem.js"></script>
    <script type="text/javascript" src="__JS__/jquery-1.8.0.min.js"></script>    
    <link type="text/css" rel="stylesheet" href="__CSS__/public.css" />
    <link type="text/css" rel="stylesheet" href="__CSS__/clinic.css" />
    <title>药品订购</title>
    <script type="text/javascript">
       
    </script>
</head>
<body>
    <div class="P_Header">
        <div class="P_main">
            <h2 class="P_title ">药品订购</h2>
            <span class="P_goBack">
            <!--<a href="/Doctor/Clinic/Clinic/index.html"><img src="/Public/Home/Saleman/images/back_icon.png" alt="" style="width:10px;height:20px;"></a>
            -->
                <a  class='h_back_1' href="/Doctor/Clinic/Clinic/index.html" id="my_back_btn"  ><i></i></a>
            </span>
            <span class="P_Header_info"><a href="/Doctor/Clinic/Clinic/clinicorder" style="font-size:20px;">我的订单</a></span>
        </div>
    </div>
    <div class="P_con drugOrder">
        <div class="P_main">
            <ul class="drugLists">
                             
            </ul>
            <div class="bg_f olBox no_pad">
           
                <ol>
                    <li>药品名称</li>
                    <li>单价</li>
                    <li>数量</li>
                </ol>
               <volist name="list" id="data">
                <ol>
                    <li>{$data.drugs_name}</li>
                    <li>￥{$data.price}</li>
                    <li>
                        <em><i class="number" id="jian" data="{$data.drugs_id}">&#xe6cc;</i></em>
                        <span id="number_{$data.drugs_id}">{$data.num}</span>
                        <em><i class="number" id="add" data="{$data.drugs_id}">&#xe600;</i></em>
                    </li>
                </ol>
                </volist>
                <p class="singleLine total">总价格：<span class="c_red foter">￥<?php echo $mess['total_price'];?></span></p>                
            </div>                
        </div>
        <div class="shopCar">
            <span><i>&#xe60a;</i></span>
            <em id="a_number"><?php echo $mess['num'];?></em>
        </div>        

        <div class="submitOrder">
            <span class="totalM">共计：<em class="c_red foter">￥<?php echo $mess['total_price'];?></em></span>
            <input type="button" value="提交订单" id="submit"/>
            <script>
             $("#submit").click(function(){
           
            		window.location.href="/Doctor/Clinic/Clinic/setelOrder/op/submit.html";
     		})
            </script>
        </div>
    </div>  
</body>
</html>
<script src = "__SaleManager__/js/androidback.js"></script>
<script>
 function back_callback() {
	history.back(-1);
} 
$(function () {
            var page = 0;

            GetData();

            
            function GetData() {
               
                $.ajax({
                    type: 'post',
                    url: '/Home/Saleman/Saleman/orderMedicine/op/list',
                    dataType: 'json',
                    data: {page: page},
                    success: function (result) {
                        page++;
                        var data = result['data'];

                        if (data == null) {
                            return;
                        }

                        var str = '<ul class="drugLists">';
                        for (var i = 0; i < data.length; i++) {
                            str+='<li> <a href="/Doctor/Clinic/Clinic/details/id/'+data[i].id+'"><div class="pic"><img src="'+data[i].cover_img+'"></div>';
                            str+='<p>'+data[i].name+'</p>';
                            str+='<div class="ov_h"><span class="c_red">￥'+data[i].price+'</span>';
                            str+='<em><i class="c_blue">&#xe60a;</i></em></div></a></li>';
                        }
                        str+='</ul>';
                        $('.drugLists').append(str);
                    },
                    error: function (xhr, type) {
                        alert('获取失败');
                    }
                });
            }
            $('.add_cart').on('click',function(){

                
            })
            $('.ok-btn').on('click', function () {
                var drugs_id = $(this).attr('pos_id');
                var num = 1;
                $.ajax({
                    url: "/Home/Saleman/Saleman/orderMedicine/op/cart",
                    type: 'post',
                    data: {drugs_id: drugs_id, num: num},
                    dataType: "json",
                    success: function (result) {
                        $("#iosDialog1").hide(200);
                        $('#iosDialog2').find('.sure-info').html(result['msg']);
                        $('#iosDialog2').find('.sure-btn').attr('pos_url', '');
                        if (result['data'] != null) {
                            var data = result['data'];
                            $('.good_num').html(data['totalNum']);
                            $('.allPrices').html(data['totalPrice']);
                        }
                        $('#iosDialog2').show(200);
                    }
                });
            });
           $(".number").click(function(){
              var type = $(this).attr("id");
              var drugs_id = $(this).attr("data");
              var number = $("#number_"+drugs_id).text();
              number = parseInt(number);
              if(type=='jian' && number==0)
              {
                 return;
              }

              $.ajax({
                url: "/Doctor/Clinic/Clinic/number",
                type: 'post',
                data: {drugs_id:drugs_id,type:type},
                dataType: "json",
                success:function(msg)
                {
                    if(msg.code==1)
                    {
                          $("#number_"+drugs_id).text(msg.number);
                          $("#a_number").text(msg.number);
                          $(".foter").text("￥"+msg.price);
                    }
                }
              });
           })
        });
    
</script>